#include "dialog.h"
#include "ui_dialog.h"
#include<QLayout>
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);

    setWindowTitle("堆栈窗体测试");
    qlist=new QListWidget(this);
    qlist->insertItem(0,"Linux1");
    qlist->insertItem(1,"Linux2");
    qlist->insertItem(2,"Linux3");
    qlist->insertItem(3,"Linux4");
    qlist->insertItem(4,"Linux5");

    stackcks=new QStackedWidget(this);
    lab1=new QLabel("Linux1 Qt");
    lab2=new QLabel("Linux2 Qt");
    lab3=new QLabel("Linux3 Qt");
    lab4=new QLabel("Linux4 Qt");
    lab5=new QLabel("Linux5 Qt");

    stackcks->addWidget(lab1);
    stackcks->addWidget(lab2);
    stackcks->addWidget(lab3);
    stackcks->addWidget(lab4);
    stackcks->addWidget(lab5);

    btn=new QPushButton(this);
    btn->setText("点击");

    QHBoxLayout *layout=new QHBoxLayout(this);
    layout->addWidget(qlist);
    layout->addWidget(stackcks);
    layout->addWidget(btn);

    connect(btn,&QPushButton::clicked,this,&Dialog::myWidgetSlots);

}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::myWidgetSlots()
{
    static int a=0;
    a++;
    a=a%5;
    stackcks->setCurrentIndex(a);
}

